from fastapi import APIRouter, Form
from starlette.requests import Request
from starlette.responses import RedirectResponse

from fastadmin.template import templates

router = APIRouter()


@router.get("/login")
async def login_view(request: Request):
    return templates.TemplateResponse("login.html", context={"request": request})


@router.post("/login")
async def login(request: Request, username: str = Form(...), password: str = Form(...)):
    return RedirectResponse(url=request.app.ADMIN_PATH, status_code=302)


@router.get("/logout")
async def logout_view():
    pass


@router.get("/signup")
async def signup_view():
    pass
